package com.fr.chart.shape3d;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.ColorInfo;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.core.ChartUtils;
import com.fr.chart.core.glyph.SoloGlyph;
import com.fr.chart.math.Object3D;
import com.fr.chart.math.Projection;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Arc2D;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Ellipse2D.Double;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;

public class Cylinder extends SoloGlyph
  implements Object3D
{
  private static final long serialVersionUID = 5570356712828640455L;
  public static final String XML_TAG = "Cyliner";
  private double start_y = 0.0D;
  private double x;
  private double y;
  private double start = 0.0D;
  private double extent = 360.0D;
  private double depth = 60.0D;
  private float R = 60.0F;
  private Projection projection = new Projection();
  private ColorInfo colorInfo = new ColorInfo();

  public Cylinder()
  {
  }

  public Cylinder(double paramDouble1, double paramDouble2, double paramDouble3)
  {
    setStart_y(paramDouble1);
    setDepth(paramDouble2);
    setR((float)paramDouble3);
  }

  public void draw(Graphics paramGraphics)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Paint localPaint = localGraphics2D.getPaint();
    Color localColor = this.colorInfo.getSeriesColor().darker();
    localGraphics2D.setColor(localColor);
    localGraphics2D.fill(bottom());
    for (int i = (int)getDepth() - 1; i > 0; --i)
    {
      localColor = colorPlus(localColor);
      localGraphics2D.setColor(localColor);
      localGraphics2D.draw(getArc2D(i));
    }
    localGraphics2D.setColor(this.colorInfo.getSeriesColor().brighter());
    localGraphics2D.fill(top());
    localGraphics2D.setPaint(localPaint);
  }

  private Color colorPlus(Color paramColor)
  {
    return new Color(Math.max(paramColor.getRed() + 1, 0), Math.max(paramColor.getGreen() + 1, 0), Math.max(paramColor.getBlue() + 1, 0));
  }

  public Arc2D bottom()
  {
    return getArc2D((int)getDepth());
  }

  public Area back()
  {
    Area localArea4;
    Area localArea5;
    Arc2D localArc2D1 = top();
    localArc2D1.setArcType(0);
    Arc2D localArc2D2 = bottom();
    localArc2D2.setArcType(0);
    double d1 = localArc2D1.getAngleStart();
    double d2 = localArc2D1.getAngleExtent();
    double d3 = d1 + d2;
    if (isInner())
    {
      localObject = new GeneralPath();
      ((GeneralPath)localObject).append(localArc2D1.getPathIterator(null), true);
      ((GeneralPath)localObject).lineTo((float)localArc2D2.getEndPoint().getX(), (float)localArc2D2.getEndPoint().getY());
      localArc2D2.setAngleStart(d3);
      localArc2D2.setAngleExtent(-d2);
      ((GeneralPath)localObject).append(localArc2D2.getPathIterator(null), true);
      return new Area((Shape)localObject);
    }
    Object localObject = this.projection.projecteeArc(getStart_y(), getR(), 0.0D, 360.0D);
    Rectangle localRectangle1 = ((Arc2D)localObject).getBounds();
    Rectangle tmp150_148 = localRectangle1;
    tmp150_148.x = (int)(tmp150_148.x + this.x);
    Rectangle tmp166_164 = localRectangle1;
    tmp166_164.y = (int)(tmp166_164.y + this.y);
    Ellipse2D.Double localDouble1 = new Ellipse2D.Double(localRectangle1.getX(), localRectangle1.getY(), localRectangle1.getWidth(), localRectangle1.getHeight());
    Point2D.Double localDouble2 = new Point2D.Double(localDouble1.getX(), localDouble1.getY());
    Point2D.Double localDouble3 = new Point2D.Double(localDouble1.getMaxX(), localDouble1.getY());
    Arc2D localArc2D3 = this.projection.projecteeArc(getStart_y() + (int)getDepth(), getR(), 0.0D, 360.0D);
    Rectangle localRectangle2 = localArc2D3.getBounds();
    Rectangle tmp285_283 = localRectangle2;
    tmp285_283.x = (int)(tmp285_283.x + this.x);
    Rectangle tmp301_299 = localRectangle2;
    tmp301_299.y = (int)(tmp301_299.y + this.y);
    Ellipse2D.Double localDouble4 = new Ellipse2D.Double(localRectangle2.getX(), localRectangle2.getY(), localRectangle2.getWidth(), localRectangle2.getHeight());
    Point2D.Double localDouble5 = new Point2D.Double(localDouble4.getX(), localDouble4.getMaxY());
    Point2D.Double localDouble6 = new Point2D.Double(localDouble4.getMaxX(), localDouble4.getMaxY());
    GeneralPath localGeneralPath = new GeneralPath();
    localGeneralPath.moveTo((float)localDouble1.getX(), (float)localDouble1.getCenterY());
    localGeneralPath.lineTo((float)localDouble1.getMaxX(), (float)localDouble1.getCenterY());
    localGeneralPath.lineTo((float)localDouble4.getMaxX(), (float)localDouble4.getCenterY());
    localGeneralPath.lineTo((float)localDouble4.getX(), (float)localDouble4.getCenterY());
    localGeneralPath.closePath();
    Area localArea1 = new Area(localDouble1);
    localArea1.add(new Area(localGeneralPath));
    localArea1.add(new Area(localDouble4));
    Area localArea2 = new Area(localArea1);
    localArea2.subtract(new Area(localDouble4));
    Area localArea3 = null;
    double d4 = Math.toDegrees(Math.asin(-get_sin_theta()));
    if (d2 < 0.0D)
      if (isAngleAtFront(d1))
        if (!(isAngleAtBack(d3)))
        {
          if (d2 > -(180.0D + 2.0D * d4))
            break label950:
          localArea3 = localArea2;
        }
        else
        {
          localArea3 = getSideArea(localArc2D1, localArc2D2, 180.0D - d4, d3, localDouble2, localDouble3, localDouble5, localDouble6);
        }
      else if (!(isAngleAtFront(d3)))
        if (d2 > -(180.0D - 2.0D * d4))
        {
          localArea3 = getSideArea(localArc2D1, localArc2D2, d1, d3, localDouble2, localDouble3, localDouble5, localDouble6);
        }
        else
        {
          localArea4 = getSideArea(localArc2D1, localArc2D2, d4, d1, localDouble2, localDouble3, localDouble5, localDouble6);
          localArea5 = getSideArea(localArc2D1, localArc2D2, d3, 180.0D - d4, localDouble2, localDouble3, localDouble5, localDouble6);
          localArea3 = new Area(localArea4);
          localArea3.add(localArea5);
        }
      else
        localArea3 = getSideArea(localArc2D1, localArc2D2, d1, d4, localDouble2, localDouble3, localDouble5, localDouble6);
    else if (d2 > 0.0D)
      if (isAngleAtFront(d1))
        if (!(isAngleAtBack(d3)))
        {
          if (d2 < 180.0D + 2.0D * d4)
            break label950:
          localArea3 = localArea2;
        }
        else
        {
          localArea3 = getSideArea(localArc2D1, localArc2D2, d4, d3, localDouble2, localDouble3, localDouble5, localDouble6);
        }
      else if (!(isAngleAtFront(d3)))
        if (d2 < 180.0D - 2.0D * d4)
        {
          localArea3 = getSideArea(localArc2D1, localArc2D2, d3, d1, localDouble2, localDouble3, localDouble5, localDouble6);
        }
        else
        {
          localArea4 = getSideArea(localArc2D1, localArc2D2, 180.0D - d4, d1, localDouble2, localDouble3, localDouble5, localDouble6);
          localArea5 = getSideArea(localArc2D1, localArc2D2, d4, d3, localDouble2, localDouble3, localDouble5, localDouble6);
          localArea3 = new Area(localArea4);
          localArea3.add(localArea5);
        }
      else
        localArea3 = getSideArea(localArc2D1, localArc2D2, 180.0D, d1, localDouble2, localDouble3, localDouble5, localDouble6);
    if (localArea3 == null)
      label950: localArea3 = new Area();
    else
      localArea3.intersect(localArea2);
    return ((Area)localArea3);
  }

  public Area front()
  {
    Area localArea4;
    Area localArea5;
    if (isInner())
      return new Area();
    Rectangle localRectangle1 = this.projection.projecteeArc(getStart_y(), getR(), 0.0D, 360.0D).getBounds();
    Rectangle tmp40_39 = localRectangle1;
    tmp40_39.x = (int)(tmp40_39.x + this.x);
    Rectangle tmp55_54 = localRectangle1;
    tmp55_54.y = (int)(tmp55_54.y + this.y);
    Ellipse2D.Double localDouble1 = new Ellipse2D.Double(localRectangle1.getX(), localRectangle1.getY(), localRectangle1.getWidth(), localRectangle1.getHeight());
    Point2D.Double localDouble2 = new Point2D.Double(localDouble1.getX(), localDouble1.getY());
    Point2D.Double localDouble3 = new Point2D.Double(localDouble1.getMaxX(), localDouble1.getY());
    Rectangle localRectangle2 = this.projection.projecteeArc(getStart_y() + (int)getDepth(), getR(), 0.0D, 360.0D).getBounds();
    Rectangle tmp160_158 = localRectangle2;
    tmp160_158.x = (int)(tmp160_158.x + this.x);
    Rectangle tmp176_174 = localRectangle2;
    tmp176_174.y = (int)(tmp176_174.y + this.y);
    Ellipse2D.Double localDouble4 = new Ellipse2D.Double(localRectangle2.getX(), localRectangle2.getY(), localRectangle2.getWidth(), localRectangle2.getHeight());
    Point2D.Double localDouble5 = new Point2D.Double(localDouble4.getX(), localDouble4.getMaxY());
    Point2D.Double localDouble6 = new Point2D.Double(localDouble4.getMaxX(), localDouble4.getMaxY());
    GeneralPath localGeneralPath = new GeneralPath();
    localGeneralPath.moveTo((float)localDouble1.getX(), (float)localDouble1.getCenterY());
    localGeneralPath.lineTo((float)localDouble1.getMaxX(), (float)localDouble1.getCenterY());
    localGeneralPath.lineTo((float)localDouble4.getMaxX(), (float)localDouble4.getCenterY());
    localGeneralPath.lineTo((float)localDouble4.getX(), (float)localDouble4.getCenterY());
    localGeneralPath.closePath();
    Area localArea1 = new Area(localDouble1);
    localArea1.add(new Area(localGeneralPath));
    localArea1.add(new Area(localDouble4));
    Area localArea2 = new Area(localArea1);
    localArea2.subtract(new Area(localDouble1));
    Arc2D localArc2D1 = top();
    localArc2D1.setArcType(0);
    Arc2D localArc2D2 = bottom();
    localArc2D2.setArcType(0);
    double d1 = localArc2D1.getAngleStart();
    double d2 = localArc2D1.getAngleExtent();
    double d3 = d1 + d2;
    Area localArea3 = null;
    double d4 = Math.toDegrees(Math.asin(-get_sin_theta()));
    if (d2 < 0.0D)
      if (isAngleAtFront(d1))
      {
        if (!(isAngleAtBack(d3)))
          if (d2 > -(180.0D + 2.0D * d4))
          {
            localArea3 = getSideArea(localArc2D1, localArc2D2, d3, d1, localDouble2, localDouble3, localDouble5, localDouble6);
          }
          else
          {
            localArea4 = getSideArea(localArc2D1, localArc2D2, 180.0D - d4, d1, localDouble2, localDouble3, localDouble5, localDouble6);
            localArea5 = getSideArea(localArc2D1, localArc2D2, d3, d4, localDouble2, localDouble3, localDouble5, localDouble6);
            localArea3 = new Area(localArea4);
            localArea3.add(localArea5);
          }
        else
          localArea3 = getSideArea(localArc2D1, localArc2D2, 180.0D - d4, d1, localDouble2, localDouble3, localDouble5, localDouble6);
      }
      else if (!(isAngleAtFront(d3)))
      {
        if (d2 > -(180.0D - 2.0D * d4))
          break label885:
        localArea3 = localArea2;
      }
      else
      {
        localArea3 = getSideArea(localArc2D1, localArc2D2, d3, d4, localDouble2, localDouble3, localDouble5, localDouble6);
      }
    else if (d2 > 0.0D)
      if (isAngleAtFront(d1))
      {
        if (!(isAngleAtBack(d3)))
          if (d2 < 180.0D + 2.0D * d4)
          {
            localArea3 = getSideArea(localArc2D1, localArc2D2, d3, d1, localDouble2, localDouble3, localDouble5, localDouble6);
          }
          else
          {
            localArea4 = getSideArea(localArc2D1, localArc2D2, 180.0D - d4, d3, localDouble2, localDouble3, localDouble5, localDouble6);
            localArea5 = getSideArea(localArc2D1, localArc2D2, d1, d4, localDouble2, localDouble3, localDouble5, localDouble6);
            localArea3 = new Area(localArea4);
            localArea3.add(localArea5);
          }
        else
          localArea3 = getSideArea(localArc2D1, localArc2D2, d1, d4, localDouble2, localDouble3, localDouble5, localDouble6);
      }
      else if (!(isAngleAtFront(d3)))
      {
        if (d2 < 180.0D - 2.0D * d4)
          break label885:
        localArea3 = localArea2;
      }
      else
      {
        localArea3 = getSideArea(localArc2D1, localArc2D2, 180.0D - d4, d3, localDouble2, localDouble3, localDouble5, localDouble6);
      }
    if (localArea3 == null)
      label885: localArea3 = new Area();
    else
      localArea3.intersect(localArea2);
    return localArea3;
  }

  public Arc2D top()
  {
    return getArc2D(0);
  }

  public GeneralPath getStartSide()
  {
    Arc2D localArc2D1 = top();
    Arc2D localArc2D2 = bottom();
    GeneralPath localGeneralPath = new GeneralPath();
    localGeneralPath.moveTo((float)localArc2D2.getCenterX(), (float)localArc2D2.getCenterY());
    localGeneralPath.lineTo((float)localArc2D2.getStartPoint().getX(), (float)localArc2D2.getStartPoint().getY());
    localGeneralPath.lineTo((float)localArc2D1.getStartPoint().getX(), (float)localArc2D1.getStartPoint().getY());
    localGeneralPath.lineTo((float)localArc2D1.getCenterX(), (float)localArc2D1.getCenterY());
    localGeneralPath.closePath();
    return localGeneralPath;
  }

  public GeneralPath getEndSide()
  {
    Arc2D localArc2D1 = top();
    Arc2D localArc2D2 = bottom();
    GeneralPath localGeneralPath = new GeneralPath();
    localGeneralPath.moveTo((float)localArc2D2.getCenterX(), (float)localArc2D2.getCenterY());
    localGeneralPath.lineTo((float)localArc2D2.getEndPoint().getX(), (float)localArc2D2.getEndPoint().getY());
    localGeneralPath.lineTo((float)localArc2D1.getEndPoint().getX(), (float)localArc2D1.getEndPoint().getY());
    localGeneralPath.lineTo((float)localArc2D1.getCenterX(), (float)localArc2D1.getCenterY());
    localGeneralPath.closePath();
    return localGeneralPath;
  }

  private Arc2D getArc2D(int paramInt)
  {
    Arc2D localArc2D = this.projection.projecteeArc(getStart_y() + paramInt, getR(), this.start, this.extent);
    Rectangle localRectangle = localArc2D.getBounds();
    Rectangle tmp34_33 = localRectangle;
    tmp34_33.x = (int)(tmp34_33.x + this.x);
    Rectangle tmp49_48 = localRectangle;
    tmp49_48.y = (int)(tmp49_48.y + this.y);
    localArc2D.setArc(localRectangle, localArc2D.getAngleStart(), localArc2D.getAngleExtent(), localArc2D.getArcType());
    return localArc2D;
  }

  public Shape getShape()
  {
    GeneralPath localGeneralPath = new GeneralPath();
    localGeneralPath.append(getArc2D(0), false);
    localGeneralPath.append(getArc2D((int)getDepth()), false);
    return localGeneralPath;
  }

  public void setProjection(Projection paramProjection)
  {
    this.projection = paramProjection;
  }

  public Projection getProjection()
  {
    return this.projection;
  }

  public void setColorInfo(ColorInfo paramColorInfo)
  {
    this.colorInfo = paramColorInfo;
  }

  public ColorInfo getColorInfo()
  {
    return this.colorInfo;
  }

  public void setStart_y(double paramDouble)
  {
    this.start_y = paramDouble;
  }

  public double getStart_y()
  {
    return this.start_y;
  }

  public void setX(double paramDouble)
  {
    this.x = paramDouble;
  }

  public double getX()
  {
    return this.x;
  }

  public void setY(double paramDouble)
  {
    this.y = paramDouble;
  }

  public double getY()
  {
    return this.y;
  }

  public void setStart(double paramDouble)
  {
    this.start = paramDouble;
  }

  public double getStart()
  {
    return this.start;
  }

  public void setExtent(double paramDouble)
  {
    this.extent = paramDouble;
  }

  public double getExtent()
  {
    return this.extent;
  }

  public void setDepth(double paramDouble)
  {
    this.depth = paramDouble;
  }

  public double getDepth()
  {
    return this.depth;
  }

  public void setR(float paramFloat)
  {
    this.R = paramFloat;
  }

  public float getR()
  {
    return this.R;
  }

  public static Point2D getArcPoint(Arc2D paramArc2D, double paramDouble)
  {
    double d1 = paramArc2D.getX() + (Math.cos(Math.toRadians(-paramDouble)) * 0.5D + 0.5D) * paramArc2D.getWidth();
    double d2 = paramArc2D.getY() + (Math.sin(Math.toRadians(-paramDouble)) * 0.5D + 0.5D) * paramArc2D.getHeight();
    return new Point2D.Double(d1, d2);
  }

  public static Area getSideArea(Arc2D paramArc2D1, Arc2D paramArc2D2, double paramDouble1, double paramDouble2, Point2D paramPoint2D1, Point2D paramPoint2D2, Point2D paramPoint2D3, Point2D paramPoint2D4)
  {
    Point2D localPoint2D1 = ChartUtils.intersectsPoint(getArcPoint(paramArc2D1, paramDouble1), getArcPoint(paramArc2D2, paramDouble1), paramPoint2D1, paramPoint2D2);
    Point2D localPoint2D2 = ChartUtils.intersectsPoint(getArcPoint(paramArc2D1, paramDouble1), getArcPoint(paramArc2D2, paramDouble1), paramPoint2D3, paramPoint2D4);
    Point2D localPoint2D3 = ChartUtils.intersectsPoint(getArcPoint(paramArc2D1, paramDouble2), getArcPoint(paramArc2D2, paramDouble2), paramPoint2D1, paramPoint2D2);
    Point2D localPoint2D4 = ChartUtils.intersectsPoint(getArcPoint(paramArc2D1, paramDouble2), getArcPoint(paramArc2D2, paramDouble2), paramPoint2D3, paramPoint2D4);
    if ((localPoint2D1 == null) || (localPoint2D2 == null) || (localPoint2D3 == null) || (localPoint2D4 == null))
      return new Area();
    GeneralPath localGeneralPath = new GeneralPath();
    localGeneralPath.moveTo((float)localPoint2D1.getX(), (float)localPoint2D1.getY());
    localGeneralPath.lineTo((float)localPoint2D2.getX(), (float)localPoint2D2.getY());
    localGeneralPath.lineTo((float)localPoint2D4.getX(), (float)localPoint2D4.getY());
    localGeneralPath.lineTo((float)localPoint2D3.getX(), (float)localPoint2D3.getY());
    localGeneralPath.closePath();
    return new Area(localGeneralPath);
  }

  private boolean isInner()
  {
    int i = this.projection.getElevation();
    int j = this.projection.getFocus();
    double d1 = j / 2.0F * getR();
    double d2 = Math.sqrt(1.0D + d1 * d1) - d1;
    return (Math.cos(Math.toRadians(i)) <= d2);
  }

  private boolean isAngleAtFront(double paramDouble)
  {
    return (Math.sin(Math.toRadians(paramDouble)) < -get_sin_theta());
  }

  private boolean isAngleAtBack(double paramDouble)
  {
    return (!(isAngleAtFront(paramDouble)));
  }

  private double get_sin_theta()
  {
    double d = Math.toRadians(this.projection.getElevation());
    int i = this.projection.getFocus();
    return (getR() * Math.pow(Math.sin(d), 2.0D) / Math.cos(d) * i);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if (str1.equals("Attr"))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("start_y")) != null)
          setStart_y(Double.valueOf(str2).doubleValue());
        if ((str2 = paramXMLableReader.getAttr("x")) != null)
          setX(Double.valueOf(str2).doubleValue());
        if ((str2 = paramXMLableReader.getAttr("y")) != null)
          setY(Double.valueOf(str2).doubleValue());
        if ((str2 = paramXMLableReader.getAttr("start")) != null)
          setStart(Double.valueOf(str2).doubleValue());
        if ((str2 = paramXMLableReader.getAttr("extent")) != null)
          setExtent(Double.valueOf(str2).doubleValue());
        if ((str2 = paramXMLableReader.getAttr("depth")) != null)
          setDepth(Double.valueOf(str2).doubleValue());
        if ((str2 = paramXMLableReader.getAttr("r")) != null)
          setR(Float.valueOf(str2).floatValue());
      }
      else if (str1.equals("Projection"))
      {
        setProjection((Projection)paramXMLableReader.readXMLObject(new Projection()));
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("Cyliner").startTAG("Attr").attr("start_y", getStart_y()).attr("x", getX()).attr("y", getY()).attr("start", getStart()).attr("extent", getExtent()).attr("depth", getDepth()).attr("r", getR()).end();
    if (getProjection() != null)
      this.projection.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof Cylinder))
      return false;
    Cylinder localCylinder = (Cylinder)paramObject;
    if (localCylinder.getStart_y() != getStart_y())
      return false;
    if (localCylinder.getX() != getX())
      return false;
    if (localCylinder.getY() != getY())
      return false;
    if (localCylinder.getStart() != getStart())
      return false;
    if (localCylinder.getExtent() != getExtent())
      return false;
    if (localCylinder.getDepth() != getDepth())
      return false;
    if (localCylinder.getR() != getR())
      return false;
    return (Equals.equals(localCylinder.getProjection(), getProjection()));
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = super.toJSONObject();
    localJSONObject.put("start", this.start);
    localJSONObject.put("x", this.x);
    localJSONObject.put("start_y", this.start_y);
    localJSONObject.put("y", this.y);
    localJSONObject.put("depth", this.depth);
    localJSONObject.put("extent", this.extent);
    localJSONObject.put("R", this.R);
    if (this.projection != null)
      localJSONObject.put("projection", this.projection.toJSONObject());
    if (this.colorInfo != null)
      localJSONObject.put("colorInfo", this.colorInfo.toJSONObject());
    return localJSONObject;
  }

  public static class CylinderSide
    implements Comparable
  {
    Cylinder cylinder;
    boolean isStart;

    public CylinderSide(Cylinder paramCylinder, boolean paramBoolean)
    {
      this.cylinder = paramCylinder;
      this.isStart = paramBoolean;
    }

    public int compareTo(Object paramObject)
    {
      double d1;
      double d2;
      CylinderSide localCylinderSide = (CylinderSide)paramObject;
      if (this.isStart)
        d1 = this.cylinder.getStart();
      else
        d1 = this.cylinder.getStart() + this.cylinder.getExtent();
      if (localCylinderSide.isStart)
        d2 = localCylinderSide.cylinder.getStart();
      else
        d2 = localCylinderSide.cylinder.getStart() + localCylinderSide.cylinder.getExtent();
      double d3 = Math.abs(d1 - 90.0D) % 360.0D;
      double d4 = Math.abs(d2 - 90.0D) % 360.0D;
      d3 = (d3 > 180.0D) ? 360.0D - d3 : d3;
      d4 = (d4 > 180.0D) ? 360.0D - d4 : d4;
      if (Math.abs(d3 - d4) < 0.05D)
      {
        if (this.cylinder.getExtent() != 0.0D)
          if (this.isStart)
            d1 = this.cylinder.getStart() + this.cylinder.getExtent() / Math.abs(this.cylinder.getExtent());
          else
            d1 = this.cylinder.getStart() + this.cylinder.getExtent() - this.cylinder.getExtent() / Math.abs(this.cylinder.getExtent());
        if (localCylinderSide.cylinder.getExtent() != 0.0D)
          if (localCylinderSide.isStart)
            d2 = localCylinderSide.cylinder.getStart() + localCylinderSide.cylinder.getExtent() / Math.abs(localCylinderSide.cylinder.getExtent());
          else
            d2 = localCylinderSide.cylinder.getStart() + localCylinderSide.cylinder.getExtent() - localCylinderSide.cylinder.getExtent() / Math.abs(localCylinderSide.cylinder.getExtent());
        d3 = Math.abs(d1 - 90.0D) % 360.0D;
        d4 = Math.abs(d2 - 90.0D) % 360.0D;
        d3 = (d3 > 180.0D) ? 360.0D - d3 : d3;
        d4 = (d4 > 180.0D) ? 360.0D - d4 : d4;
      }
      if (d3 < d4)
        return -1;
      if (d3 > d4)
        return 1;
      return 0;
    }
  }
}